package com.rush.rushaicodemother.config;

import dev.langchain4j.model.chat.ChatModel;
import dev.langchain4j.model.chat.StreamingChatModel;
import dev.langchain4j.model.openai.OpenAiChatModel;
import dev.langchain4j.model.openai.OpenAiStreamingChatModel;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.time.Duration;

@Configuration
@ConfigurationProperties(prefix = "langchain4j.open-ai.chat-model")
//@ConfigurationProperties(prefix = "langchain4j.community.dashscope.chat-model")
@Data
public class ReasoningStreamingChatModelConfig {
    private String baseUrl;
    private String apiKey;
    private String modelName;
    /**
     * 推理流式模型
     */
    @Bean
    public StreamingChatModel reasoningStreamingChatModel() {
        return OpenAiStreamingChatModel.builder()
                .apiKey(apiKey)
                .baseUrl(baseUrl)
                .modelName(modelName)
                .logRequests( true)
                .logResponses(true)
                .timeout(Duration.ofMinutes(5))
                .build();
    }
    @Bean
    public ChatModel chatModel() {
        return OpenAiChatModel.builder()
                .apiKey(apiKey)
                .baseUrl(baseUrl)
                .modelName(modelName)
                .logRequests( true)
                .logResponses(true)
                .timeout(Duration.ofMinutes(5))
                .build();
    }
//    @Bean
//    public StreamingChatModel reasoningStreamingChatModel() {
//        return OpenAiStreamingChatModel.builder()
//                .apiKey("sk-mj9mAQj3p1cpfTTjZRCHAQ61zPQZmpkAtC5g0ctQZTSOE7lO")
//                .baseUrl("https://globalai.vip/v1")
//                .modelName("claude-3-7-sonnet")
//                .logRequests(true)
//                .logResponses(true)
//                .timeout(Duration.ofMinutes (10))
//                .build();
//    }
}
